<?php
declare(strict_types=1);

namespace app\common\model;

use think\Model;

class CommonBase extends Model
{
    public const CACHE_EXPIRE_TIME = 30 * 86400; // 单位:秒

    public const IS_ENABLE_STATUS  = 1;
    public const IS_DISABLE_STATUS = 2;

    /*** 字段 ***/

    // 是否系统字段
    public const FIELD_IS_SYSTEM   = 1;
    public const FIELD_IS_CUSTOMER = 2;

    // 是否必填
    public const FIELD_IS_REQUIRE     = 1;
    public const FIELD_IS_NOT_REQUIRE = 2;

    // 是否列表展示
    public const FIELD_IS_SHOW_LIST   = 1;
    public const FIELD_IS_HIDDEN_LIST = 2;

    public const FIELD_TYPE_NAME_MAP = [
        'input'    => '单行文本',
        'textarea' => '多行文本',
        'radio'    => '单选',
        'image'    => '图片',
        'file'     => '文件',
        'datetime' => '日期时间',
        'date'     => '日期',
        'editor'   => '富文本',
        'map'      => '地图',
    ];

    public const FIELD_TYPE_DB_SUFFIX_MAP = [
        'input'    => 'varchar',
        'textarea' => 'varchar',
        'radio'    => 'varchar',
        'image'    => 'varchar',
        'file'     => 'varchar',
        'datetime' => 'varchar',
        'date'     => 'varchar',
        'editor'   => 'text',
        'map'      => 'text',
    ];

    /*** 栏目 ***/

    // 是否跳转到子栏目
    public const CATEGORY_IS_NOT_REDIRECT_CHILD = 1;
    public const CATEGORY_IS_REDIRECT_CHILD     = 2;

    /*** 菜单 ***/
    public const IS_MENU   = 1;
    public const IS_BUTTON = 2;

    /*** 业务类型 ***/
    public const PLATFORM_MENU = 1;
    public const BACKEND_MENU  = 2;


    public const AD_ATTACHMENT_TYPE             = 'ad';
    public const CATEGORY_ATTACHMENT_TYPE       = 'category';
    public const ARTICLE_ATTACHMENT_TYPE        = 'article';
    public const WEBSITE_CONFIG_ATTACHMENT_TYPE = 'config';

    public function __construct(array $data = [], string $connection = 'mysql')
    {
        parent::__construct($data);
        $this->connection = $connection;
    }
}
